<template>
	<view class="page">
		<view class="info_box">
			<view class="info_box_base">
				<view class="info_box_base_title" style="font-weight: bold;">站点信息</view>
				<view class="info_box_base_item">所属地区：{{baseInfo.region}}</view>
				<view class="info_box_base_item">站点编号：{{baseInfo.site_number}}</view>
				<view class="info_box_base_item" v-if="baseInfo.operators == 1">运营商：中国移动</view>
				<view class="info_box_base_item" v-if="baseInfo.operators == 2">运营商：中国电信</view>
				<view class="info_box_base_item" v-if="baseInfo.operators == 3">运营商：中国联通</view>
				<view class="info_box_base_item" style="color: red;" v-if="baseInfo.status == 3">拒绝原因：<text
						class="base_item_dd">{{baseInfo.rejection}}</text></view>

				<view class="info_box_base_item" style="display: flex;flex-direction: row;align-items: center;margin-top: 14rpx;">
					<text>站点名称：</text>
					<u--input @chage="chageTitle" @blur="changeTitle" v-model="baseInfo.title"
						:disabled="editTitle?false:true" placeholder="请输入站点名称" border="bottom"></u--input>
					<view class="" @click="editTitle = true" style="color: rgb(25, 175, 201);font-size: 25rpx;">编辑
					</view>
				</view>
				<view class="info_box_base_item" style="display: flex;flex-direction: row;align-items: center;margin-top: 14rpx;">
					<text>站点地址：</text>
					<u--input placeholder="请输入站点地址" @blur="changeAddress" :disabled="editAddress?false:true"
						v-model="baseInfo.site_address" border="bottom"></u--input>
					<view class="" @click="editAddress = true" style="color: rgb(25, 175, 201);font-size: 25rpx;">编辑
					</view>
				</view>
				
				<view class="info_box_base_item" style="display: flex;flex-direction: row;align-items: center;margin-top: 14rpx;">
					<text>联系人：</text>
					<u--input placeholder="请输入联系人" @blur="changeLxr" :disabled="editLxr?false:true"
						v-model="baseInfo.contacts" border="bottom"></u--input>
					<view class="" @click="editLxr = true" style="color: rgb(25, 175, 201);font-size: 25rpx;">编辑
					</view>
				</view>
				
				<view class="info_box_base_item" style="display: flex;flex-direction: row;align-items: center;margin-top: 14rpx;">
					<text>电话：</text>
					<u--input placeholder="请输入电话" maxlength="11" @blur="changeTel" :disabled="editTel?false:true"
						v-model="baseInfo.phonetel" border="bottom"></u--input>
					<view class="" @click="editTel = true" style="color: rgb(25, 175, 201);font-size: 25rpx;">编辑
					</view>
				</view>
				
				<!-- <view class="info_box_base_item">联系人：{{baseInfo.contacts}}</view>
				<view class="info_box_base_item">电话：{{baseInfo.phonetel}}</view> -->
			</view>


			<!-- <view class="info_box_base_item">
					<text>站点名称：</text>
					<u--input @chage="chageTitle" @blur="changeTitle" v-model="baseInfo.title"
						:disabled="editTitle?false:true" placeholder="请输入站点名称" border="bottom"></u--input>
					<view class="" @click="editTitle = true" style="color: rgb(25, 175, 201);font-size: 25rpx;">编辑
					</view>
				</view> -->

			<view class="info_box_base" >
				<view class="info_box_base_title" style="font-weight: bold;">电话巡检内容</view>

				<view class="info_box_base_item"
					style="margin: 20rpx 0;display: flex;flex-direction: row;align-items: center;">
					<view>手机信号是否稳定</view>
					<view style="margin-left: 100rpx;">
						<u-radio-group @change="chooseR" v-model="params.is_mobile_phonesignal">
							<u-radio shape="circle" style="margin-right: 40rpx;" size="14" label-size="13" name="2"
								label="是"></u-radio>
							<u-radio shape="circle" size="14" label-size="13" label="否" name="1"></u-radio>
						</u-radio-group>
					</view>
				</view>

				<view class="info_box_base_item">
					<view>语音通话</view>
					<view style="margin: 20rpx 0;">
						<u-checkbox-group @change="chooseRR" v-model="params.conversation_id"
							style="min-width: 690rpx;flex-wrap: wrap;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
							<u-checkbox size="13" style="min-width: 33%;margin-bottom: 20rpx;" labelSize="13"
								:name="item.id" :label="item.title" v-for="(item,index) in yythdata"
								:key="index"></u-checkbox>

						</u-checkbox-group>
					</view>
				</view>

				<view class="info_box_base_item">
					<view>网络使用</view>
					<view style="margin: 20rpx 0;">
						<u-checkbox-group @change="chooseRRR" v-model="params.network_id"
							style="min-width: 690rpx;flex-wrap: wrap;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
							<u-checkbox size="13" :name="item.id" v-for="(item,index) in wlsydata" :key="index"
								style="min-width: 33%;margin-bottom: 20rpx;" labelSize="13"
								:label="item.title"></u-checkbox>
						</u-checkbox-group>
					</view>
				</view>
				<view class="gcxt_b_wy_reason">
					<text>其他问题描述：</text>
					<u--input placeholder="请输入具体说明" v-model="params.other_problem_desc" border="none"></u--input>
				</view>

				<view class="info_box_base_title" style="font-weight: bold;margin: 20rpx 0;">巡检结论</view>
				<view class="info_box_base_item">
					<u-checkbox-group @change="chooseRRRR" v-model="params.conclusion_id"
						style="min-width: 690rpx;flex-wrap: wrap;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
						<u-checkbox size="13" v-for="(item,index) in xjjldata" :name="item.id" :key="index"
							style="min-width: 33%;margin-bottom: 20rpx;" labelSize="13"
							:label="item.title"></u-checkbox>
					</u-checkbox-group>
				</view>
			</view>

			<view class="btn" @click="confirm">确认</view>
		</view>
	</view>
</template>

<script>
	import {
		api,
		apiBaseUrl,
		http
	} from '@/config/common.js'
	export default {
		data() {
			return {
				editLxr:false,
				editTel:false,
				
				editTitle: false,
				editAddress: false,
				yythdata: [],
				wlsydata: [],
				xjjldata: [],
				params: {
					is_mobile_phonesignal: '',
					conversation_id: [],
					network_id: [],
					conclusion_id: [],
					other_problem_desc: ''
				},
				id: '',
				packid: '',
				site_id: '',
				baseInfo: {}
			}
		},
		components: {},
		filters: {},
		mounted() {},
		onLoad(e) {
			this.id = e.id
			this.packid = e.packid
			this.site_id = e.site_id
			this.getBaseInfo()
			this.lookInfo()
			this.getYyth()
			this.getYlsy()
			this.getXjjl()
		},
		onShow() {},
		onPageScroll(e) {},
		beforeDestroy() {},
		methods: {
			changeTitle() {
				let title = this.baseInfo.title
				api.post('/api/shop/onsiteworksitesh_edoit', {
					work_sitesh_id: this.site_id,
					type: 1,
					title: title
				}).then(res => {
					let rst = res.data
					if (rst.code == 1) {
						this.editTitle = false
					}
				}).catch(err => {

				})
			},
			changeTel(){
				let phonetel = this.baseInfo.phonetel
				api.post('/api/shop/onsiteworksitesh_edoit', {
					work_sitesh_id: this.site_id,
					type: 5,
					phonetel: phonetel
				}).then(res => {
					let rst = res.data
					if (rst.code == 1) {
						this.editTel = false
					}
				}).catch(err => {
				
				})
			},
			changeLxr(){
				let contacts = this.baseInfo.contacts
				api.post('/api/shop/onsiteworksitesh_edoit', {
					work_sitesh_id: this.site_id,
					type: 4,
					contacts: contacts
				}).then(res => {
					let rst = res.data
					if (rst.code == 1) {
						this.editLxr = false
					}
				}).catch(err => {
				
				})
			},
			changeAddress() {
				let title = this.baseInfo.site_address
				api.post('/api/shop/onsiteworksitesh_edoit', {
					work_sitesh_id: this.site_id,
					type: 2,
					site_address: title
				}).then(res => {
					let rst = res.data
					if (rst.code == 1) {
						this.editAddress = false
					}
				}).catch(err => {

				})
			},
			lookInfo() {
				uni.showLoading({})
				api.post('api/shop/submt_onsitetelinfo', {
					onsite_id: this.id,
					work_package_id: this.packid,
					work_site: this.site_id,
					type: 2
				}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						if (rst.data) {
							rst.data.is_mobile_phonesignal = rst.data.is_mobile_phonesignal.toString()
							rst.data.conversation_id = rst.data.conversation_id ? rst.data.conversation_id.map(
								item => parseInt(item, 10)) : []
							rst.data.conclusion_id = rst.data.conclusion_id ? rst.data.conclusion_id.map(item =>
								parseInt(item, 10)) : []
							rst.data.network_id = rst.data.network_id ? rst.data.network_id.map(item => parseInt(
								item, 10)) : []
							this.params = rst.data

						}
					}

				}).catch(err => {
					uni.hideLoading()
				})
			},
			chooseRRRR(e) {
				this.params.conclusion_id = e
			},
			chooseRRR(e) {
				this.params.network_id = e
			},
			chooseRR(e) {
				this.params.conversation_id = e
			},
			chooseR(e) {
				this.params.is_mobile_phonesignal = e
			},
			getBaseInfo() {
				uni.showLoading({})
				api.post('/api/shop/look_onsite_work_site_sh', {
					onsite_id: this.id,
					work_sitesh_id: this.site_id
				}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						this.baseInfo = rst.data
					}

				}).catch(err => {
					uni.hideLoading()
				})
			},
			//巡检结论
			getXjjl() {
				uni.showLoading({})
				api.post('/api/shop/onsite_conversation_network_conclusion', {
					type: 2
				}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						this.xjjldata = rst.data
					}
				}).catch(err => {
					uni.hideLoading()
				})
			},
			//语音通话
			getYyth() {
				uni.showLoading({})
				api.post('/api/shop/onsite_conversation_network_conclusion', {
					type: 0
				}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						this.yythdata = rst.data
					}
				}).catch(err => {
					uni.hideLoading()
				})
			},
			//网络使用
			getYlsy() {
				uni.showLoading({})
				api.post('/api/shop/onsite_conversation_network_conclusion', {
					type: 1
				}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						this.wlsydata = rst.data
					}
				}).catch(err => {
					uni.hideLoading()
				})
			},
			confirm() {
				let rst = this.params
				rst.conclusion_id = rst.conclusion_id ? rst.conclusion_id.join(',') : ''
				rst.conversation_id = rst.conversation_id ? rst.conversation_id.join(',') : ''
				rst.network_id = rst.network_id ? rst.network_id.join(',') : ''
				uni.showLoading({})
				api.post('/api/shop/submt_onsitetelinfo', {
					onsite_id: this.id,
					work_package_id: this.packid,
					work_site: this.site_id,
					type: 1,
					...rst
				}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						uni.navigateTo({
							url: '/pages/xj/home'
						})
					} else {
						uni.$u.toast(rst.msg)
					}

				}).catch(err => {
					uni.hideLoading()
				})
			}
		}
	};
</script>

<style scoped>
	::v-deep .uni-input-input {
		font-size: 26rpx;
	}

	::v-deep .uni-input-placeholder {
		font-size: 26rpx;
	}

	.info_box_base_item_1_item_i {
		width: 30%;
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 3%;
	}

	.down_link {
		color: rgb(11, 125, 218);
		font-size: 25rpx;
	}

	.btn {
		width: 500rpx;
		height: 80rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		margin: 0 auto;
		margin-top: 40rpx;
		background-color: rgb(70, 179, 255);
		color: #fff;
		border-radius: 40rpx;
		font-size: 32rpx;
	}

	::v-deep .uni-input-input {
		font-size: 26rpx;
	}

	::v-deep .uni-input-placeholder {
		font-size: 26rpx;
	}

	.gcxt_b_wy_reason {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.gcxt_b_wy {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin: 20rpx 0;
	}

	.info_box_base {
		border: 1px solid rgb(235, 229, 229);
		padding: 20rpx;
		font-size: 26rpx;
		margin-top: 20rpx;
	}

	.info_box_base_item {
		line-height: 50rpx;
		word-wrap: break-word;
		/* 允许在单词内换行 */
		overflow-wrap: break-word;
		/* 同上，现代浏览器推荐使用这个属性别名 */
		white-space: normal;
		/* 允许自动换行 */
	}

	.info_box {
		width: 710rpx;
		margin: 0 auto;
		padding-bottom: 40rpx;
	}

	page {
		background-color: #fff;
	}
</style>